<include file="public@header"/>
<style type="text/css">
    .pic-list li {
        margin-bottom: 5px;
    }
</style>

</head>
<body>

<h1>-修改-</h1>

<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('AdminIndex/add2')}">修改界面</a></li>
    </ul>
    <form action="{:url('AdminIndex/edit_post')}" method="post" class="form-horizontal js-ajax-form margin-top-20" onsubmit="return validate_form(this)">
        <div class="row">
            <div class="col-md-9">
                <input type="hidden" name="task_id" value="{$task_id}">
                <input type="hidden" name="receive_id" value="{$list.receive_id}">
                <table class="table table-bordered">

                    <tr>
                        <th>处理人<span class="form-required">*</span></th>
                        <td id="title_td" class="must_choose" onclick="setBackground()">
                            <input class="form-control" type="text" name="title"
                                   id="title" required value="{$list.title}" placeholder="请输入任务标题"/>
                        </td>
                    </tr>
                    <tr>
                        <th>处理人电话<span class="form-required">*</span></th>
                        <td id="title_td2" class="must_choose" onclick="setBackground()">
                            <input class="form-control" type="text" name="receiver"
                                   id="title2" required value="{$list.receiver}" placeholder="请输入任务标题"/>
                        </td>
                    </tr>
                    <tr>
                        <th>任务内容1<span class="form-required">*</span></th>
                        <td>

                            <textarea placeholder="请输入任务内容" name="content" type="text" style="width:770px; height:100px">{$list.content}</textarea>
                        </td>
                    </tr>
                    <tr>
                        <th>任务内容2<span class="form-required">*</span></th>
                        <td>

                            <textarea placeholder="请输入任务内容" name="task_content" type="text" style="width:770px; height:100px">{$list.task_content}</textarea>
                        </td>
                    </tr>

                    <tr>
                        <th>
                            <label>截止日期<span class="form-required">*</span></label>
                        </th>
                        <td id="deadline_td" class="must_choose" onclick="setBackground()">
                            <input type="text" class="form-control js-bootstrap-datetime" name="deadline"
                                   value="{$list.deadline}"
                                   style="width: 160px;" autocomplete="off">

                        </td>
                    </tr>


                </table>

                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-primary js-ajax-submit">改</button>
                        <a class="btn btn-default" href="{:url('AdminIndex/index')}">{:lang('BACK')}</a>
                    </div>
                </div>
            </div>

        </div>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
    $(function () {

        editorcontent = new baidu.editor.ui.Editor();
        editorcontent.render('content');
        try {
            editorcontent.sync();
        } catch (err) {
        }

        $('.btn-cancel-thumbnail').click(function () {
            $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#thumbnail').val('');
        });

    });

    function doSelectCategory() {
        var selectedCategoriesId = $('#js-categories-id-input').val();
        openIframeLayer("{:url('AdminCategory/select')}?ids=" + selectedCategoriesId, '请选择分类', {
            area: ['700px', '400px'],
            btn: ['确定', '取消'],
            yes: function (index, layero) {
                //do something

                var iframeWin          = window[layero.find('iframe')[0]['name']];
                var selectedCategories = iframeWin.confirm();
                if (selectedCategories.selectedCategoriesId.length == 0) {
                    layer.msg('请选择分类');
                    return;
                }
                $('#js-categories-id-input').val(selectedCategories.selectedCategoriesId.join(','));
                $('#js-categories-name-input').val(selectedCategories.selectedCategoriesName.join(' '));
                //console.log(layer.getFrameIndex(index));
                layer.close(index); //如果设定了yes回调，需进行手工关闭
            }
        });
    }
    function setBackground() {
        $("td.must_choose").attr("style","background-color: #ffffff");
        $("td.form-inline").attr("style","background-color: #ffffff");
    }
    function validate_form(thisform)
    {

        if (thisform.title.value==null||thisform.title.value==''){
            $("td#title_td").attr("style","background-color: #ffe5e5 ");
            return false
        }
        if (thisform.deadline.value==null||thisform.deadline.value==''){
            $("td#deadline_td").attr("style","background-color: #ffe5e5 ");
            return false
        }
        var file = $("input#file-video").val()

        if (!file) {
            $("td#files_td").attr("style","background-color: #ffe5e5 ");
            return false
        }
        return true

    }
</script>
</body>
</html>
